package br.com.eduquiz.session;

import br.com.eduquiz.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("telefoneList")
@Restrict("#{s:hasRole('AdministradorGrupo')}")
public class TelefoneList extends EntityQuery<Telefone> {

	private static final long serialVersionUID = -1622589205455710431L;

	private static final String EJBQL = "select telefone from Telefone telefone";

	private static final String[] RESTRICTIONS = {
			"lower(telefone.contato) like lower(concat(#{telefoneList.telefone.contato},'%'))",
			"lower(telefone.numero) like lower(concat(#{telefoneList.telefone.numero},'%'))",
			"lower(telefone.ramal) like lower(concat(#{telefoneList.telefone.ramal},'%'))", };

	private Telefone telefone = new Telefone();

	public TelefoneList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(10);
	}

	public Telefone getTelefone() {
		return telefone;
	}
}
